package com.cmc.cloud.cmclink.doc.controller.admin;

import cn.hutool.core.bean.BeanUtil;
import com.cmc.cloud.cmclink.doc.vo.tblisustampemail.TblisustampEmailCreateReqVO;
import com.cmc.cloud.cmclink.doc.vo.tblisustampemail.TblisustampEmailPageReqVO;
import com.cmc.cloud.cmclink.doc.vo.tblisustampemail.TblisustampEmailRespVO;
import com.cmc.cloud.cmclink.doc.vo.tblisustampemail.TblisustampEmailUpdateReqVO;
import com.cmes.framework.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;


import com.cmes.framework.common.pojo.PageResult;

import com.cmc.cloud.cmclink.doc.entity.TblisustampEmailDO;
import com.cmc.cloud.cmclink.doc.service.TblisustampEmailService;


/**
 * {table.classComment}前端接口Controller
 * 
 * @author codegen
 */
@Tag(name = "管理后台 - 不同代理的申请记录确认人和确认人邮箱配置")
@RestController
@Validated
public class TblisustampEmailController {

    @Resource
    private TblisustampEmailService tblisustampEmailService;

    @Operation(summary = "创建不同代理的申请记录确认人和确认人邮箱配置")
    @PreAuthorize("@ss.hasPermission('doc:tblisustamp-email:create')")
    public CommonResult<Void> createTblisustampEmail(@Valid @RequestBody TblisustampEmailCreateReqVO createReqVO) {
        tblisustampEmailService.createTblisustampEmail(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新不同代理的申请记录确认人和确认人邮箱配置")
    @PreAuthorize("@ss.hasPermission('doc:tblisustamp-email:update')")
    public CommonResult<Void> updateTblisustampEmail(@Valid @RequestBody TblisustampEmailUpdateReqVO updateReqVO) {
        tblisustampEmailService.updateTblisustampEmail(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除不同代理的申请记录确认人和确认人邮箱配置")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('doc:tblisustamp-email:delete')")
    public CommonResult<Void> deleteTblisustampEmail(@PathVariable("id") Long id) {
        tblisustampEmailService.deleteTblisustampEmail(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得不同代理的申请记录确认人和确认人邮箱配置")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('doc:tblisustamp-email:query')")
    public CommonResult<TblisustampEmailRespVO> getTblisustampEmail(@PathVariable("id") Long id) {
        TblisustampEmailDO tblisustampEmail = tblisustampEmailService.getTblisustampEmail(id);
        return CommonResult.success(BeanUtil.copyProperties(tblisustampEmail, TblisustampEmailRespVO.class));
    }

    @Operation(summary = "获得不同代理的申请记录确认人和确认人邮箱配置列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @PreAuthorize("@ss.hasPermission('doc:tblisustamp-email:query')")
    public CommonResult<List<TblisustampEmailRespVO>> getTblisustampEmailList(@RequestParam("ids") Collection<Long> ids) {
        List<TblisustampEmailDO> list = tblisustampEmailService.getTblisustampEmailList(ids);
        return CommonResult.success(BeanUtil.copyToList(list,TblisustampEmailRespVO.class));
    }

    @Operation(summary = "获得不同代理的申请记录确认人和确认人邮箱配置分页")
    @PreAuthorize("@ss.hasPermission('doc:tblisustamp-email:query')")
    public CommonResult<PageResult<TblisustampEmailRespVO>> getTblisustampEmailPage(@Valid TblisustampEmailPageReqVO pageVO) {
        PageResult<TblisustampEmailDO> pageResult = tblisustampEmailService.getTblisustampEmailPage(pageVO);
        List<TblisustampEmailRespVO> results = BeanUtil.copyToList(pageResult.getList(), TblisustampEmailRespVO.class);
        return CommonResult.success(new PageResult<>(results,pageResult.getTotal()));
    }
}
